#include<iostream>
using namespace std;
const int N = 1e5 + 10;
int arr[N], tree[N];
int n;
int lowbit(int x)
{
	return x & -x;
}

void add(int x, int v)
{
	for (int i = x; i <= n; i += lowbit(i)) {
		tree[i] += v;
	}
}

int get_sum(int x)
{
	int ans = 0;
	for (int i = x; i; i -= lowbit(i)) {
		ans += tree[i];
	}
	return ans;
}
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> arr[i];
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		int x = arr[i];
		ans += get_sum(n) - get_sum(x);
		add(x, 1);
	}
	cout << ans << endl;
	return 0;
}